package com.car.loan.project.xr.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.Collection;
import java.util.List;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.car.loan.project.xr.mapper.CustomerGuarantorMapper;
import com.car.loan.project.xr.domain.CustomerGuarantor;
import com.car.loan.project.xr.service.ICustomerGuarantorService;

/**
 * 担保人Service业务层处理
 *
 * @author ruoyi
 * @date 2019-11-03
 */
@Service
public class CustomerGuarantorServiceImpl implements ICustomerGuarantorService {

    @Autowired
    private CustomerGuarantorMapper customerGuarantorMapper;

    /**
     * 查询担保人
     *
     * @param id 担保人ID
     * @return 担保人
     */
    @Override
    public CustomerGuarantor selectCustomerGuarantorById(Long id) {
        return customerGuarantorMapper.selectById(id);
    }

    /**
     * 查询担保人列表
     *
     * @param customerGuarantor 担保人
     * @return 担保人
     */
    @Override
    public List<CustomerGuarantor> selectCustomerGuarantorList(
        CustomerGuarantor customerGuarantor) {
        QueryWrapper<CustomerGuarantor> queryWrapper = new QueryWrapper<>(customerGuarantor);
        return customerGuarantorMapper.selectList(queryWrapper);
    }


    @Override
    public IPage<CustomerGuarantor> selectPage(IPage<CustomerGuarantor> page,
        QueryWrapper<CustomerGuarantor> queryWrapper) {
        return customerGuarantorMapper.selectPage(page, queryWrapper);
    }

    /**
     * 新增担保人
     *
     * @param customerGuarantor 担保人
     * @return 结果
     */
    @Override
    public int insertCustomerGuarantor(CustomerGuarantor customerGuarantor) {

        return customerGuarantorMapper.insert(customerGuarantor);
    }

    /**
     * 修改担保人
     *
     * @param customerGuarantor 担保人
     * @return 结果
     */
    @Override
    public int updateCustomerGuarantor(CustomerGuarantor customerGuarantor) {

        return customerGuarantorMapper.updateById(customerGuarantor);
    }

    /**
     * 删除担保人对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteCustomerGuarantorByIds(Collection<Long> ids) {
        return customerGuarantorMapper.deleteBatchIds(ids);
    }

    /**
     * 删除担保人信息
     *
     * @param id 担保人ID
     * @return 结果
     */
    @Override
    public int deleteCustomerGuarantorById(Long id) {
        return customerGuarantorMapper.deleteById(id);
    }
}
